//
//  threeViewController.m
//  iosFramework
//
//  Created by Farben on 2020/8/6.
//  Copyright © 2020 Farben. All rights reserved.
//

#import "ZJDetailViewController.h"

@interface ZJDetailViewController ()

@property (nonatomic, strong)UITextView* textView;

@property (nonatomic, strong)UILabel *titlelabel;

@end

@implementation ZJDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColor.blueColor;
    [self.view addSubview:self.textView];
    
    [self.view addSubview:self.titlelabel];
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view);
        make.centerX.equalTo(self.view);
        make.width.mas_equalTo(300);
        make.height.mas_equalTo(200);
    }];
    
    
    if(self.parameters){
        self.textView.text = [NSString stringWithFormat:@" %@",[self dictionaryToJson:self.parameters]];
    }else{
        self.textView.text = @"没有参数";
    }
    
      // 1.创建信号
    RACSignal * signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        // 3.发送信号
        [subscriber sendNext:@"发送信号"];
        return nil;
    }];

    // 2.订阅信号
    [signal subscribeNext:^(id  _Nullable x) {
        NSLog(@"接收内容：%@", x);
    } error:^(NSError * _Nullable error) {
        
    }];
    
}

- (NSString*)dictionaryToJson:(NSDictionary *)dic

{
    NSError *parseError = nil;

    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];

    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}


-(UITextView*)textView{
    if(!_textView){
        _textView = [[UITextView alloc]init];
        _textView.font = SYSTEMFONT(16);
        _textView.userInteractionEnabled = YES;
        _textView.contentOffset = CGPointMake(0, 100);
        
    }
    return _textView;
}

-(UILabel*)titlelabel{
    if(!_titlelabel){
        _titlelabel = [[UILabel alloc]init];
        _titlelabel.text = @"Parameters";
        
    }
    return _titlelabel;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
